<template>
	<view class="groupactivelist">
		<view class="groupactivelist_top_block">
			<view class="groupauditlist_tabs">
				<view @click="changeTabs(0)"
					:class="params.type==0?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">全部</view>
				<view @click="changeTabs(1)"
					:class="params.type==1?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">待审核</view>
				<view @click="changeTabs(2)"
					:class="params.type==2?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">未通过</view>
				<view @click="changeTabs(3)"
					:class="params.type==3?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">已通过</view>
			</view>
		</view>
		<view v-for="(item,index) in list" :key="item.huodong_id" class="groupactivelist_cell">
			<view @click="goInfo(item.huodong_id)">
				<view class="info">
					<view v-if="item.status == 1" class="a_audit">待审核</view>
					<view v-if="item.status == 2" class="a_no">未通过</view>
					<view v-if="item.status == 3" class="a_pass">已通过</view>
					<view class="display_flex" style="justify-content: space-between">
						<view class="flex-1 ellipsis">活动名称：
							<text>{{item.title}}</text>
						</view>
					</view>
					<view class="mt-5">
						<view>活动日期：{{item.start_time?item.start_time.substring(0,10):''}} 至
							{{item.end_time?item.end_time.substring(0,10):''}}</view>
					</view>
					<view class="mt-5" v-if="item.company_name">
						<view class="ellipsis">经销商名称：{{item.company_name}}</view>
					</view>
				</view>
			</view>
			<view class="mt-10 display_flex" style="justify-content:flex-end;">
				<view class="group_public_btn_mini" @click="goInfo(item.huodong_id)">核销详情</view>
			</view>
		</view>
		<view class="page_bottom_loading" :style="'padding-bottom:'+pdbottom+'rpx;'">{{loadingTitle}}</view>
	</view>
</template>

<script>
	import {
		getSocGroupActiveVerifyList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				params: {
					title: '',
					club_id: '',
					type: 0,
					page: 1,
					size: 15,
				},
				list: [],
				loadingTitle: '',
				onlinePic: app.globalData.onlinePic,
				picUrl: app.globalData.picUrl,
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets.bottom +
					30 : 30,
			};
		},
		onShow() {

			if (uni.getStorageSync('userinfo').is_staff == 0) {
				uni.switchTab({
					url: '/pages/index/index'
				})
			} else {
				if (uni.getStorageSync('onload')) {
					this.params.page = 1
					this.list = []
					this.getSocGroupActiveVerifyList()
					uni.removeStorage({
						key: 'onload'
					})
				}
			}
		},
		onLoad(options) {
			if (uni.getStorageSync('userinfo').is_staff != 0) {
				this.club_id = options.club_id
				this.params.club_id = options.club_id
				this.getSocGroupActiveVerifyList()
			}
			var params = {
				event_code: 'SOC-车友会活动核销审核管理',
				path: 'pages/groupmanage/socgroupactivelist',
				event_id: '',
				title: '',
				source_page: '',
				value: '',
			}
			app.BurialPoint(params)
		},
		methods: {
			getSocGroupActiveVerifyList() {
				getSocGroupActiveVerifyList(this.params).then(res => {
					if (res.state == 1) {
						this.list = [...this.list, ...res.data.data]
						this.current_page = res.data.current_page
						this.last_page = res.data.last_page
						if (this.list.length == 0) {
							this.loadingTitle = "- 暂无更多 -"
						}
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},

			changeTabs(index) {
				this.params.type = index
				this.params.page = 1
				this.list = []
				this.getSocGroupActiveVerifyList()
			},
			goInfo(id) {
				uni.navigateTo({
					url: '/pages/groupmanage/socgroupactiveverifyinfo?club_id=' + this.club_id +
						'&isCheck=1&huodong_id=' +
						id
				})
			},
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.list = []
			this.getSocGroupActiveVerifyList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.current_page < this.last_page) {
				this.showLoading = true
				this.params.page = this.params.page + 1
				this.getSocGroupActiveVerifyList()
			} else {
				this.showLoading = false
				if (this.list.length > 0) {
					this.loadingTitle = "- 已经到底了 -"
				} else {
					this.loadingTitle = "- 暂无更多 -"
				}

			}
		}
	}
</script>

<style lang="scss">
	.groupactivelist {
		padding: 0 30rpx 50rpx 30rpx;

		.groupactivelist_top_block {
			padding-top: 30rpx;
			position: sticky;
			top: 0;
			z-index: 1;
			background-color: #ffffff;

			.groupauditlist_tabs {
				height: 80rpx;
				font-size: 26rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				border-radius: 8rpx;
				border: 2rpx solid #E9E9E9;

				.groupauditlist_tabs_cell {
					width: 20%;
					height: 26rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-right: 4rpx solid #000000;
				}

				.groupauditlist_tabs_cell:last-child {
					border-right: 0;
				}

				.tabs_on {
					color: #00A0DC;
				}
			}
		}

		.groupactivelist_cell {
			font-size: 28rpx;
			margin-top: 40rpx;
			padding: 20rpx;
			border-radius: 8rpx;
			border: 2rpx solid #F7F7F7;
			background-color: #F7F7F7;

			.info {
				background-color: #F0F0F0;
				border-radius: 8rpx;
				padding: 20rpx;
				font-size: 26rpx;
				position: relative;

				.huodong_status {
					width: 70rpx;
					height: 30rpx;
					position: absolute;
					right: 0;
					top: 0;
				}
			}

			.label {
				color: #999;
				padding-right: 10rpx;
			}
		}

		.mastbar {
			position: fixed;
			bottom: 200rpx;
			right: 30rpx;
			z-index: 1;

			.mastbar_post {
				width: 120rpx;
				height: 120rpx;
				background-color: #00A0DC;
				border-radius: 100rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.release {
				width: 40rpx;
				height: 44rpx;
			}
		}

		.button {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			background-color: #00A0DC;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 140rpx;
		}
	}
</style>